package com.cloud.wms.ui.main.activity;

import android.content.Intent;
import android.os.Message;

import com.cloud.core.http.BaseObserver;
import com.cloud.core.utils.BarUtils;
import com.cloud.wms.R;
import com.cloud.wms.app.FineExApplication;
import com.cloud.wms.base.BaseActivity;
import com.cloud.wms.tools.RxUtils;
import com.cloud.wms.ui.main.entity.WarehouseEntity;

import java.util.concurrent.TimeUnit;

import io.reactivex.Observable;

/**
 * @Author:Chen
 * @Date: 2021-01-14 15:23
 * @Description:
 */
public class SplashActivity extends BaseActivity {

    @Override
    protected int getResId() {
        return R.layout.activity_main_splash;
    }

    @Override
    protected void setupComponent() {
    }

    @Override
    protected void initBar() {
    }

    @Override
    protected void initToolBar() {

    }

    @Override
    protected void initEvent() {
        BarUtils.setNavBarVisibility(this, false);
        FineExApplication.component().loginCache().setWarehouseInfo(new WarehouseEntity());
        Observable
                .timer(1000, TimeUnit.MILLISECONDS)
                .compose(RxUtils.threadSwitch())
                .subscribe(new BaseObserver<Long>() {
                    @Override
                    public void onSuccess(Long aLong) {
                        Intent intent = new Intent(mContext, LoginActivity.class);
                        startActivity(intent);
                        finish();
                    }

                    @Override
                    public void onError(String msg) {
                        error(msg);
                    }
                });
    }

    @Override
    public void onSuccess(Message message) {

    }
}
